<?php


namespace App\Notifications\Wechat;


use App\Internals\UserInternal;

class CourseEnd extends Notification
{
    public function notify($userId, $courseLevel, $datetime, $nextCourseId, $seriesName)
    {
        $templateId = 'GqOmrvqBB-jQPdVsNltuUml4LB7zm-qjvTkCI2niJko';
        $socialAccount = UserInternal::getSocialAccount($userId);

        if ($nextCourseId) {
            $url = config('app.base_url') . '/?#/goods/detail?id=' . $nextCourseId;
        } else {
            $url = config('app.base_url') . '/?#/menu/course';
        }

        $data = [
            'first'    => sprintf("%s 家长您好，您购买的课程即将推送完，请及时购买下一等级课程以免耽误您宝贝学习，如已购买可忽略该提醒信息！\n", $socialAccount['nickname']),
            'keyword1' => [sprintf('%s - Level%s课程', $seriesName, $courseLevel), '#FF6F6F'],
            'keyword2' => [$datetime."\n", '#FF6F6F'],
            'remark'   => ['点击进入课程购买页面', '#FF6F6F'],
        ];
        $this->send($socialAccount['openId'], $templateId, $url, $data);
    }
}
